<template>
  <el-dialog title="蚂蚁风控" :visible.sync="dialogVisible" width="700px">
    <div v-loading="loading">
      <el-row :gutter="20">
        <el-divider content-position="left">
          <h5>{{ cert_name }}-蚂蚁风控</h5>
        </el-divider>
        <el-row :gutter="20">
          <el-col :span="16" style="text-align:center;border: 0px;height: 25px;">
            <div class="grid-content bg-purple">
              风控生成时间：{{ start_at }}
            </div>
          </el-col>
        </el-row>
      </el-row>
      <el-row :gutter="20">
        <el-divider content-position="left">
          <h5>蚂蚁风控信息</h5>
        </el-divider>
        <el-descriptions class="margin-top" :column="2" border>
          <el-descriptions-item label="风控级别">
            <span :style="level == '高危' ? 'color:red' : level == '优质' ? 'color:green' : ''">{{ level }}</span>
          </el-descriptions-item>
        </el-descriptions>
      </el-row>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dialogVisible = false">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getAntData } from '@/api/order'
export default {
  props: {
    editItem: {
      type: Object,
      default: () => ({})
    },
  },
  data() {
    return {
      dialogVisible: false,
      cert_name: '',
      start_at: '',
      level: '',
      loading: false
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }
    }
  },
  methods: {
    getList() {
      const params = { orderId: this.editItem.id }
      this.loading = true
      getAntData(params).then(res => {
        this.loading = false
        this.cert_name = res.cert_name
        this.start_at = res.start_at
        this.level = res.data[0].risk_T0
      }).catch(e => {
        this.loading = false
        this.dialogVisible = false
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
